﻿using Analyse.DrawingPerformance.Contract;
using Analyse.DrawingPerformance.Model;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Columns;
using BenchmarkDotNet.Attributes.Exporters;
using System.Collections.Generic;

namespace Analyse.DrawingPerformance
{
    [RPlotExporter, RankColumn]
    public class EngineBenchmark
    {
        private List<BaseDrawElement> _drawElements;

        [GlobalSetup]
        public void Setup()
        {
            this._drawElements = new List<BaseDrawElement>();
            this._drawElements.Add(new TextDrawElement(100, 50, "A demo text", 50, "#ff0000"));
            this._drawElements.Add(new TextDrawElement(300, 50, "A demo text", 80, "#00ff00"));
            this._drawElements.Add(new TextDrawElement(600, 50, "A demo text", 120, "#0000ff"));
            this._drawElements.Add(new TextDrawElement(500, 500, "   ", 120, "#000000", @"Ressources\Font Awesome 5 Free-Solid-900.otf"));
            this._drawElements.Add(new ImageDrawElement(100, 200, @"Ressources\logo.png"));
            this._drawElements.Add(new ImageDrawElement(100, 300, @"Ressources\logo.png"));
            this._drawElements.Add(new ImageDrawElement(100, 400, @"Ressources\logo.png"));
            this._drawElements.Add(new ImageDrawElement(100, 500, @"Ressources\logo.png"));
        }

        [Benchmark]
        public void ImageProcessorFullHd()
        {
            IDrawingEngine drawingEngine = new ImageProcessorDrawingEngine();
            drawingEngine.Draw(1920, 1080, this._drawElements);
        }

        [Benchmark]
        public void SkiaSharpFullHd()
        {
            IDrawingEngine drawingEngine = new SkiaSharpDrawingEngine();
            drawingEngine.Draw(1920, 1080, this._drawElements);
        }

        [Benchmark]
        public void DefaultDotNetFullHd()
        {
            IDrawingEngine drawingEngine = new DefaultDotNetDrawingEngine();
            drawingEngine.Draw(1920, 1080, this._drawElements);
        }

        [Benchmark]
        public void ImageProcessorFullHdWithoutDrawing()
        {
            IDrawingEngine drawingEngine = new ImageProcessorDrawingEngine();
            drawingEngine.Draw(1920, 1080, null);
        }

        [Benchmark]
        public void SkiaSharpFullHdWithoutDrawing()
        {
            IDrawingEngine drawingEngine = new SkiaSharpDrawingEngine();
            drawingEngine.Draw(1920, 1080, null);
        }

        [Benchmark]
        public void DefaultDotNetFullHdWithoutDrawing()
        {
            IDrawingEngine drawingEngine = new DefaultDotNetDrawingEngine();
            drawingEngine.Draw(1920, 1080, null);
        }
    }
}

